using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EventTriggerCollisionMono : MonoBehaviour
{
    public delegate void EventTriggerDelegate(Collider obj);
    public EventTriggerDelegate onTriggerEnter;
    public EventTriggerDelegate onTriggerExit;
    public EventTriggerDelegate onTriggerStay;

    public delegate void EventCollisionDelegate(Collision obj);
    public EventCollisionDelegate onCollisionEnter;
    public EventCollisionDelegate onCollisionExit;
    public EventCollisionDelegate onCollisionStay;


    public static EventTriggerCollisionMono Get(GameObject obj)
    {
        if (obj == null)
            return null;

        return obj.GetOrAddComponent<EventTriggerCollisionMono>();
    }

    private void OnTriggerEnter(Collider other)
    {
        onTriggerEnter?.Invoke(other);
    }

    private void OnTriggerExit(Collider other)
    {
        onTriggerExit?.Invoke(other);
    }

    private void OnTriggerStay(Collider other)
    {
        onTriggerStay?.Invoke(other);
    }


    private void OnCollisionEnter(Collision collision)
    {
        onCollisionEnter.Invoke(collision);
    }

    private void OnCollisionExit(Collision collision)
    {
        onCollisionExit.Invoke(collision);
    }

    private void OnCollisionStay(Collision collision)
    {
        onCollisionStay.Invoke(collision);
    }

}
